Using the Command-Line Interface
You can start CODESYS.exe from the command line with the following options and arguments.
Syntax:
<installation folder>CODESYS.exe --<Option>
Note
If you have used the CODESYS Installer to install multiple CODESYS instances on your computer, then you need to use the --additionalfolder
option to specify the instance to be launched.
Tip
Paths or option parameters must be written inside straight quotation marks when they contain spaces, dashes, or slash marks.
Option: --additionalfolder
Applies only to installations made with the CODESYS Installer:
If you have installed multiple instances of a CODESYS version and want to start one of the instances from the command line, then the following applies: In addition to the profile, you also need to specify the absolute path of the AddionalFolder/<instance name>
with the --additionalfolder
option.
Background: The CODESYS Installer creates an AdditionalFolders
subfolder in the installation directory in the CODESYS
folder. In this folder, there is a separate subfolder for each CODESYS instance with the individual files for profile, PlugIns, and PackageDB. For the first installed instance, the subfolder is named Default
. Additional instances are given the installation name assigned during installation.
You can see the absolute path to be specified for --additionalfolder
in CODESYS Installer when you click the Change button in the tile of the relevant instance. It is registered as the Location.
Syntax:
--additionalfolder=<AdditionalFolders\<instance installation name>>
Two instances of CODESYS 3.5.18.20 have been installed on your computer with the CODESYS Installer: one for service technicians, one for developers. You want to run the Service
instance via a StartServiceScript.py
script from command line. To do this, specify the --additionalfolder option after the --profile option on the command line as follows:
"C:\Program Files (x86)\CODESYS3.5.18.20\CODESYS\Common\CODESYS.exe" --profile="CODESYS V3.5 SP18 --additionalfolder="C:\Program Files\CODESYS 3.5.18.20\CODESYS\AdditionalFolders\Service" --runscript="D:\Dokumente\Scripting\StartServiceScript.py"--scriptargs:'username password 3.14 "path=\"C:\temp\\\""'–noUI
Option: --culture (language of the user interface)
CODESYS is started in the specified language.
Syntax:
--culture=<Culture>
<culture>
: Typical language codes are as follows: de, en, fr, it, es, zh-CHS.
Starting CODESYS with the user interface in English:
CODESYS.exe --culture=en
Option: --profile (CODESYS profile)
CODESYS is started directly with the specified profile. When you start CODESYS without this option, the Select Profile opens.
Syntax:
--profile="<profile name>"
<profile name>
: You need to specify the profile name exactly as it is displayed in the splash screen of the development system or in the start menu on your computer.
CODESYS.exe --culture=de --profile="CODESYS V3.6"
Option: --compare (start project comparison)
After CODESYS is started, the comparison of two CODESYS projects is begun immediately. After the option, first specify the "current project" and then the "reference project" as arguments. CODESYS starts and opens the Project Comparison – Differences view.
Syntax:
--compare="<path of project file>" "<path of reference project file>"
CODESYS.exe --compare "D:\proj\project1.project" "D:\proj\project2.project"
Option: --project (open CODESYSproject)
CODESYS is started and the specified project is opened.
Syntax:
--project="<path of project file>"
<path of project file>
: File path of project
Open the test
project:
CODESYS.exe --culture=de --project="D:\projects\test.project"
Option: --projectarchive (open CODESYS project archive)
CODESYS is started, the specified project archive is extracted, and the project is opened.
Syntax:
--projectarchive="<path of projectarchive file>"
<path of project archive file>
: File path of project archive
Extract the test.projectarchive
and open the project in the development system:
CODESYS.exe --projectarchive="D:\projects\test.projectarchive"
Option: --runscript (run script)
The specified script file is run by CODESYS.
| CODESYS runs the You need to provide the complete path of the script file. |
| Use this option with the |
| Use this option with the The CODESYS user interface is not opened. CODESYS outputs all errors, warnings, compiler reports, and command-line messages generated from the script. The script messages (1: Severity Text) can be separated from other messages (2: Severity FatalError, Error, Warning, Information) with the |
| Use this option with the |
| Use this option with the If you do not specify |
| Use this option with the
|
start /b /wait CODESYS.exe --runscript="D:\Script\ArgvAnd__main__Test.py" --scriptargs:'username password 3.14 "path=\"C:\temp\\"'
Script file: ArgvAnd__main__Test.py
from __future__ import print_function import sys print("sys.argv: ", len(sys.argv), " elements:") for arg in sys.argv: print(" - ", arg) print() print("__name__: ", __name__)
Output result: stdout
:
sys.argv: 6 elements: - D:\TestScripts\ArgvAnd__main__Test.py - username - password - 3.14 - path= "C:temp" __name__: __main__
For more information about the __name__
global variable, see the Python documentation.
start /b /wait CODESYS.exe --runscript="D:\Script\AmpelTest.py" --noUI 1>ScriptMessages.txt
CODESYS passes all messages which are generated by the script to the ScriptMessages.txt
file. Other messages are printed to the command line.
start /b /wait CODESYS.exe --runscript="D:\Script\AmpelTest.py" --noUI 2>NUL
CODESYS suppresses all messages, except for script messages. The script messages are printed to the command line.
The following initdebug.py
script was tested successfully with pydevd
-based debuggers, such as PyDev / LiClipse and PyCharm. To use this script, start CODESYS with the following command line:
--profile="Fanta Development Build" --scriptdebugger="D:\test\charmdebug\initdebug.py"
File: initdebug.py
:
from _future_ import print_function from _future_ import unicode_literals import sys sys.path.append(r"D:\test\Env2\Lib\site-packages\pycharm-debug.egg") import pydevd def scriptdebuggersetup(): pydevd.settrace('localhost', port=51234, stdoutToServer=True, stderrToServer=True) def scriptdebuggershutdown(): pydevd.stoptrace()
For more information see: Using Scripts and http://docs.python.org/tutorial/modules.html
Option: --ignorewhitespace (ignore whitespace in project comparison)
If you add this option after the option --compare <project1> <project2>
, then whitespace is ignored in the project comparison. Note that semantically relevant spaces, for example in STRING
literals, are still taken into account.
Syntax
--compare="<path of project file>" "<path of reference project file>" --ignorewhitespace="true"|"false"
CODESYS.exe --compare "D:\proj\project1.project" "D:\proj\project2.project" --ignorewhitespace="true"
Option: --ignorecomments (ignore comments in project comparison)
If you add this option after the option --compare <project1> <project2>
, then comments are ignored in the project comparison.
Syntax:
--compare="<path of project file>" "<path of reference project file>" --ignorecomments="true"|"false"
CODESYS.exe --compare "D:\proj\project1.project" "D:\proj\project2.project" --ignorecomments="true"
Option: --ignoreproperties (ignore object properties in project comparison)
If you add this option after the option --compare <project1> <project2>
, then object properties (permissions, compile settings, directories, bitmaps, etc.) are ignored in the project comparison.
Syntax:
--compare="<path of project file>" "<path of reference project file>" --ignoreproperties="true"|"false"
CODESYS.exe --compare "D:\proj\project1.project" "D:\proj\project2.project" --ignoreproperties="true"
Option: --skipunlicensedplugins (do not load components without a license)
CODESYS is started. In this case, the query as to whether unlicensed components should still be loaded is skipped. If so, then CODESYS does not silently load these components.
CODESYS.exe –skipunlicensedplugins
Option: --signaturethumbprint (thumbprint of the certificate which is used for signing compiled libraries)
If you add this option after the option --project="<path of project file>"
, then the project is opened and the thumbprint of the certificate for signing compiled libraries is passed.
Syntax:
--signaturethumbprint="<thumbprint of digital signature>"
CODESYS.exe --project="D:\projects\test.project" signaturethumbprint="3E96C9B61010CBDC3186021A1CAA64946DDCAAF3"
Option: --enforcesignedcompiledlibraries (enforce signing of compiled libraries)
If you add this option after the option --project="<path of project file>"
, then the Enforce signing of compiled libraries option is enabled in the project in the Security Screen on the User tab.
Important
When the Security Screen is opened and closed again, the current settings are applied in the user options, even when no active changes have been made.
Syntax:
--enforcesignedcompiledlibraries
CODESYS.exe --project="D:\projects\test.library" --enforcesignedcompiledlibraries
Option: --timestampingserverurl (set the time stamp server address)
If you add this option after the option --project="<path of project file>"
, then the Internet address of the RFC-3161 time stamp server (Timestamping server) is set
in the project in the Security Screen on the User tab.
Important
When the Security Screen is opened and closed again, the current settings are applied in the user options, even when no active changes have been made.
Syntax:
--timestampingserverurl="<URL of RFC-3161 timestamping server>"
CODESYS.exe --timestampingserverurl="http://timestamp.comodoca.com/rfc3161"
Option: --enableEventLog
CODESYS is started and all command executions are recorded in the Windows event log. The records are located in the Windows Event Viewer under Applications and Services Logs → AP.
When using this option for the first time, CODESYS has to be started with administrator permissions.
Syntax:
--enableEventLog="CommandManager"
Option: --ForceDisconnectAfterInactivity
For this CODESYS session, the time of inactivity after which the connection to the controller is automatically terminated is set to the specified time (in seconds). The value specified in this option overrides the value set in the CODESYS options in the Online category for this CODESYS session.
If the value is set to 0, then the connection to the controller will not be automatically terminated after a specific period of inactivity. For this CODESYS session, this disables the disconnect option in the CODESYS options.
Syntax:
--ForceDisconnectAfterInactivity="<value in seconds>"
<value in seconds> : [10, 10800] | 0
After 300 seconds of inactivity, the connection to the controller is automatically terminated.
--ForceDisconnectAfterInactivity="300"